trovefandomcom_es-20200215-history
Módulo:NewDecoPage
local data = {} function data.main(frame) --Sets Language to English local lang = mw.language.getContentLanguage() -- Input from template local blueprint = frame.args'blueprint' local var1 = frame.args'var1' local var2 = frame.args'var2' local biomes = frame.args'biome' local visualEffect = frame.args'effect' local ingame = frame.args'ingame' local quote = frame.args'quote' local description = frame.args'description' local emitLight = frame.args'emitLight' local pageName = frame.args'pageName' local itemSet = frame.args'set' -- ci# = Crafting Item # -- ca# = Crafting Amount # local values = { frame.args'ci1', frame.args'ca1', frame.args'ci2', frame.args'ca2', frame.args'ci3', frame.args'ca3', frame.args'ci4', frame.args'ca4', frame.args'ci5', frame.args'ca5', frame.args'ci6', frame.args'ca6' } -- ra = Result Amount local ra = frame.args'ra' -- Modified Page Name for disambiguous deco local Modname = pageName if string.find(pageName, ')') ~= nil then local p,_ = string.find(pageName, '%b()') Modname = string.sub(pageName, 1, p - 2) end -- Expanded Template Variables local workbench = frame:expandTemplate{title='NewDecoPage/Variable', args={Type='tool', Biome=biomes}} local varBiome = frame:expandTemplate{title='NewDecoPage/Variable', args={Type='biome', Biome=biomes}} local recipe = frame:expandTemplate{title='NewDecoPage/Variable', args={Type='recipe', Biome=biomes}} -- Function variables local crafting = data.craft(workbench, ra, values, frame, lang) local quotation = data.quote(quote, frame) local designer = data.designer(blueprint) local categories = data.category(emitLight, designer, varBiome, recipe, pageName) if (description nil or description '') then description = data.description(emitLight, workbench, pageName, itemSet, Modname) end local infobox = data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, Modname, frame) -- Finished product return infobox .. quotation .. description .. crafting .. categories end -- Categories function data.category(emitLight, designer, varBiome, recipe, pageName) local result = 'Category: DecorationCategory: Placeable' if string.lower(emitLight) 'yes' then result = result .. 'Category:Luminous' end if (designer ~= nil and designer ~= '') then result = result .. '['..'.. designer .. ']' end if (varBiome ~= nil and varBiome ~= '') then result = result .. '['..'.. varBiome .. ']' end if (recipe ~= nil and recipe ~= '') then --Test if item is part of recipe item local exclude = {} for _, v in pairs(mw.loadData('Module:DecoList/' .. varBiome .. '/Exclude')) do excludev = true end if not excludepageName then result = result .. '['..'.. recipe .. ']' end end return result end -- Crafting function data.craft(workbench, ra, array, frame, language) if (array1 ~= nil and array1 ~= '') then local values = { 'tool' = workbench, 'resultAmount' = ra } --Assigns values to crafting ingrediant and amount local count = 1 for n=1,12 do if (arrayn ~= nil and arrayn ~= '') then if tonumber(arrayn) nil then values'item'..count = arrayn else values'amount'..count = language:formatNum(tonumber(arrayn)) count = count + 1 end else count = count + 1 end end return frame:preprocess('\n Crafting \n' .. frame:expandTemplate{title='Crafting recipe', args=values}) else return '' end end -- Quote detection function data.quote(quote, frame) if (quote ~= nil and quote ~= '') then return frame:expandTemplate{title='Description', args={quote, 'Item Tooltip'}} .. ' ' else return '' end end --Isolate designer from blueprint function data.designer(blueprint) local designer = 'Trove Team' if (blueprint ~= nil and blueprint ~= '') then if string.find(blueprint, ']') ~= nil then local p,q = string.find(blueprint, '%b[]') designer = string.sub(blueprint, p + 1, q - 1) -- exception code exception = mw.loadData('Module:NewDecoPage/Designer') if exceptionstring.lower(designer) ~= nil then designer = exceptionstring.lower(designer) else designer = string.lower(designer):gsub("^%l", string.upper) end end end return designer end --Item infobox function data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, Modname, frame) -- Variation blueprints local ids = string.lower(blueprint) local imageData = ' ' if (var1 ~= nil and var1 ~= '') then ids = ids .. ' ' .. string.lower(var1) imageData = imageData .. ' - Variation1= ' if (var2 ~= nil and var2 ~= '') then ids = ids .. ' ' .. string.lower(var2) imageData = imageData .. ' - Variation2= ' end end -- Image tabber if (visualEffect ~= nil and visualEffect ~= '') then imageData = imageData .. ' - Effect = ' end if (ingame ~= nil and ingame ~= '') then imageData = imageData .. ' - Ingame = ' else imageData = imageData .. ' - Ingame = ' end imageData = imageData .. '}}' -- Remove type2 field if empty if (varBiome ~= nil and varBiome ~= '') then -- Changes type2 link to category link if in the table local seasons = { 'Geode' = 'Geode', 'Spring' = 'Spring', 'Summer' = 'Summer', 'Winter' = 'Winter' } if seasonsvarBiome ~= nil then varBiome = '' .. varBiome .. '' else varBiome = '' .. varBiome .. '' end end -- Inputs for Item infobox template local values = { 'nombre' = Modname, 'id' = ids, 'tradeable' = 'yes', 'tipo' = 'Decoración', 'tipo2' = varBiome, 'colocable' = 'Cornerstone - Club World', 'designer' = '' .. designer .. '', 'imagen' = frame:preprocess(imageData) } return frame:expandTemplate{titulo='Objeto infobox', args=values} .. '\n' end -- Item desciption function data.description(emitLight, workbench, pageName, itemSet, Modname) -- Start of result local result = 'The ' .. Modname .. '' .. ' is a placable' -- Decoration is luminous if string.lower(emitLight) 'yes' then result = result .. ', luminous' end -- 2nd part of result result = result .. ' decoration' --Decoration is craftable if (workbench ~= nil and workbench ~= '') then result = result .. ' that is crafted through the ' .. workbench .. '' end -- Decoration is a banner local geode = false local currentSect = nil local sections = { 'Top', 'Bottom' } if string.find(pageName, 'Banner') ~= nil then local i,_ = string.find(pageName, 'Banner') if i + 7 <= string.len(pageName) then -- If Geode banner if string.find(pageName, 'Spire Banner') ~= nil then geode = true end if geode then table.insert(sections, 2, 'Lower Middle') table.insert(sections, 2, 'Upper Middle') result = result .. '. Like other Geode spire banners, the ' .. pageName .. ' can be combined with the' else table.insert(sections, 2, 'Middle') result = result .. '. Like other decorational banners, the ' .. pageName .. ' can be combined with the' end -- Determines which section the banner is for n, part in ipairs(sections) do if string.find(pageName, part) ~= nil then currentSect = sectionsn table.remove(sections, n) break end end -- Generates links to other parts if geode then result = result .. ' [.. string.gsub(pageName, currentSect , sections[1) .. '|' .. sections1 .. ']], [.. string.gsub(pageName, currentSect , sections[2) .. '|' .. sections2 .. ']], and [.. string.gsub(pageName, currentSect , sections[3) .. '|' .. sections3 .. ']]' else result = result .. ' [.. string.gsub(pageName, currentSect , sections[1) .. '|' .. sections1 .. ']] and [.. string.gsub(pageName, currentSect , sections[2) .. '|' .. sections2 .. ']]' end result = result .. ' sections to create the full banner' end end result = result .. '.' return result end return data